﻿namespace System.ComponentModel
{
    using System.Collections.Generic;
    using System.Data.Entity.Core.Common;
    using System.Data.Entity.Core.Metadata.Edm;
    using System.Data.Entity.Utilities;
    using System.Linq;

    internal class ParameterDescriptor
    {
        #region Fields

        private readonly string _name;
        private readonly EdmType _edmType;
        private readonly EdmType _storeType;

        #endregion

        private ParameterDescriptor()
        { }

        internal ParameterDescriptor(string name, Type clrType, DbProviderManifest providerManifest)
        {
            this._name = name;
            this._edmType = PrimitiveType.GetEdmPrimitiveTypes().Single(t => t.ClrEquivalentType.Equals(clrType));
            this._storeType = providerManifest.GetStoreType(TypeUsage.CreateDefaultTypeUsage(_edmType)).EdmType;
        }

        internal string Name
        {
            get { return this._name; }
        }

        internal EdmType EdmType
        {
            get { return this._edmType; }
        }

        internal EdmType StoreType
        {
            get { return this._storeType; }
        }
    }
}
